
package ui.adapter;

import android.content.Context;
import android.graphics.Color;
import android.widget.TextView;

import net.ck.hzq.R;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import Utils.StringUtil;
import base.BaseViewHolder;
import base.SuperBaseAdapter;
import ui.model.RewardsDetailsBean;
import util.SysUtils;


/**
 * 新钱包奖励适配器
 * Created by chenjian on 19/2/27.
 */
public class RewardsDetailsAdapter extends SuperBaseAdapter<RewardsDetailsBean> {

    List<RewardsDetailsBean> mData = new ArrayList<>();
    Context mContext;
    int mType = 0;

    public RewardsDetailsAdapter(Context context, List<RewardsDetailsBean> data, int type) {
        super(context, data);
        mContext = context;
        mData = data;
        mType = type;
    }

    @Override
    protected void convert(BaseViewHolder holder, final RewardsDetailsBean item, final int position) {
        TextView time = holder.getView(R.id.item_rewards_details_time);
        TextView title = holder.getView(R.id.item_rewards_details_title);
        TextView money = holder.getView(R.id.item_rewards_details_money);
        TextView number = holder.getView(R.id.item_rewards_details_number);
        switch (mType) {
            case 1://购买奖
                time.setText(SysUtils.sf6.format(new Date(item.getBusinessTime())));
                title.setText(item.getEntityName());
                money.setText(StringUtil.getFormatPrice(item.getAmount()) + "元");
                number.setText(item.getSnCount() + "台");
                break;
            case 2://推广奖
                time.setText(SysUtils.sf6.format(new Date(item.getBusinessTime())));
                title.setText(item.getEntityName());
                money.setText(StringUtil.getFormatPrice(item.getAmount()) + "元");
                number.setText(item.getSnCount() + "台");
                break;
            case 3://培养奖
                time.setText(SysUtils.sf6.format(new Date(item.getBusinessTime())));
                title.setText(item.getEntityName());
                number.setText(item.getSnCount() + "台");
//                number.setText("");
                break;
            case 4://会员奖
                time.setText(SysUtils.sf6.format(new Date(item.getBusinessTime())));
                title.setText(item.getEntityName());
                money.setText("+" + StringUtil.getFormatPrice(item.getAmount()) + "元");
                number.setText("购买会员:" + StringUtil.getFormatPrice(item.getMemberAmount()) + "元");
                number.setTextColor(Color.parseColor("#FF0E0E"));
                break;
            case 5://成长奖
                time.setText(SysUtils.sf6.format(new Date(item.getBusinessTime())));
                title.setText(item.getEntityName());
                money.setText(item.getSnCount() + "台");
                number.setText("激活");
                break;
            case 6://挑战奖
                time.setText(SysUtils.sf6.format(new Date(item.getBusinessTime())));
                title.setText(item.getEntityName());
                money.setText(StringUtil.getFormatPrice(item.getAmount()) + "元");
//                number.setText("");
                break;
            case 7://导师奖
                time.setText(SysUtils.sf6.format(new Date(item.getBusinessTime())));
                title.setText(item.getSn());
                money.setText(StringUtil.getFormatPrice(item.getAmount()) + "元");
//                number.setText("");
                break;
            default:
                break;
        }
    }

    @Override
    protected int getItemViewLayoutId(int position, RewardsDetailsBean item) {
        //        if (item.getTaskType().equals("1")) {
//            return R.layout.item_collection_watch;
//        } else {
//            return R.layout.item_collection_play;
//        }
        return R.layout.item_rewards_details;
    }

}
